package edu.zut.arrays;

import java.util.Arrays;

public class ArrayTest {

    public static void main(String[] args) {

        int[] scores = {65, 89, 56, 78, 45, 69, 89, 59};
        //打印及格的成绩
        for (int i = 0; i < scores.length; i++) {
            if (scores[i] >= 60)
                System.out.println("及格的成绩：" + scores[i]);
        }

        /**
         * int[] arr= {65,89,56,78,45,69,59}   升序排序
         *            45，
         *   先找最小的      6
         *                  5
         *                  4
         *                  3
         *                  2
         *                  1
         */
        int[] arr = {65, 89, 56, 78, 45, 69, 59};
        // i = 0
        for (int i = 0; i <= arr.length - 1; i++) {

            for (int j = i + 1; j <= arr.length - 1 ; j ++){
                //依次进行比较
                if (arr[i] > arr[j]){
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));

        //冒泡  选择

//        int[] arr = {10, 20};
//
//      ArrayIndexOutOfBoundsException 数组下标越界
        System.out.println(arr[7]);






    }

}
